package qq_clinet.src.com.hzk.qq_view;

import qq_clinet.src.com.hzk.qquser_service.service;

import java.io.IOException;
import java.util.Scanner;

/**
 * @auoter:jackh
 */

public class qqview {
    private qq_clinet.src.com.hzk.qquser_service.service service=new service();
    boolean loop = true;

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        new qqview().mainMenu();
    }
    //菜单界面
    public void mainMenu() throws IOException, ClassNotFoundException {
        while (loop) {
            System.out.println("=============欢迎登录网络通讯系统================");
            System.out.println("\t\t 1.登陆系统");
            System.out.println("\t\t 9.退出系统");
            System.out.println("请输入数字进行选择");
            Scanner sc = new Scanner(System.in);
            String key = sc.next();
            switch (key) {
                case "1":
                    System.out.println("请输入您的用户名：");
                    String userid=sc.next();
                    System.out.println("请输入您的密  码：");
                    String passwd=sc.next();
                    //?
                    if (service.checkueser(userid,passwd)){
                        System.out.println("============欢迎 "+userid+"登录系统==============");
                        while (loop){
                            System.out.println("==============网络通信系统二级菜单(用户 "+userid+")==============");
                            System.out.println("\t\t 1.显示在线用户");
                            System.out.println("\t\t 2.群发信息");
                            System.out.println("\t\t 3.私聊消息");
                            System.out.println("\t\t 4.发送文件");
                            System.out.println("\t\t 9.退出系统");
                            Scanner sc1=new Scanner(System.in);
                            String key1=sc1.next();
                            switch (key1){
                                case "1":
                                    service.userlist();
                                    break;
                                case "2":
                                    System.out.println("请输入您想对大家说的话");
                                    String s=sc.next();
                                    service.talk_all_about(s);
                                    break;
                                case "3":
                                    System.out.println("请输入您想私聊的用户 ：");
                                    String user_id =sc.next();
                                    System.out.println("请输入您想对"+user_id+"用户说的话");
                                    String taik_about=sc.next();
                                    service.si_talk(user_id,taik_about);
                                    break;
                                case "4":
                                    break;
                                case "9":
                                    loop=false;
                                    service.exitsend();

                                    System.out.println("====您已退出二级界面回到主页，请重新登录或者退出系统====");
                                    break;
                            }
                        }
                    }else{
                        System.out.println("用户名或密码错误！/该用户已在线！请重新登录或退出系统！");

                    }
                    break;
                case "9":
                    loop=false;

                    break;
            }
        }

    }
}
